<!DOCTYPE html>
<html>
<head>
<title>Agate Admin Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="img/favicon.ico">
<link id="bs-css" href="bcs/css/bootstrap.min.css" rel="stylesheet">
<link href="css/charisma.app.css" rel="stylesheet">
<script src="bcs/js/jquery.min.js"></script>
<script src="bcs/js/bootstrap.min.js"></script>
<script src="/js/jquery.validate.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="js/jquery.history.js"></script>
<script src="js/charisma.app.js"></script>
<script type="text/javascript">
	$(document).ready(function() {

		$("#tip").hide();

		$("form").submit(function(event) {
			event.preventDefault();
			var username = $("#username").val();
			if (!username) {
				$("#tip").show().html("Please input your Username");
				$("#username").closest('.input-group').addClass('has-error');
				return;
			}
			var password = $("#password").val();
			if (!password) {
				$("#tip").show().html("Please input your Password");
				$("#password").closest('.input-group').addClass('has-error');
				return;
			}
			$.ajax({
				type : 'POST',
				url : '/uac/authen/login',
				contentType : 'application/json',
				data : JSON.stringify({
					username : username,
					password : password
				}),
				dataType : 'json',
				success : function(data) {
					if (data && data.code === 1 && data.result) {
						window.location.href = "/view/index.html";
					} else {
						$("#tip").show().html("Username or Password is error");
					}
				},
				error : function(req, err, cause) {
					$("#tip").show().html("Please retry again!");
				}
			});

		});

	});
</script>
</head>
<body>
	<div class="ch-container">
		<div class="row">

			<div class="row">
				<div class="col-md-12 center login-header">
					<h2>Welcome to Agate Admin</h2>
				</div>
				<!--/span-->
			</div>
			<!--/row-->

			<div class="row">
				<div class="well col-md-5 center login-box">
					<div id="tip" class="alert alert-info">Please login with your Username and Password.</div>
					<form class="form-horizontal" action="/login" method="post">
						<fieldset>
							<div class="input-group input-group-lg">
								<span class="input-group-addon"><i class="glyphicon glyphicon-user red"></i></span> <input id="username" name="username" type="text" class="form-control" placeholder="Username">
							</div>
							<div class="clearfix"></div>
							<br>
							<div class="input-group input-group-lg">
								<span class="input-group-addon"><i class="glyphicon glyphicon-lock red"></i></span> <input id="password" name="password" type="password" class="form-control" placeholder="Password">
							</div>
							<div class="clearfix"></div>
							<p class="center col-md-5">
								<button type="submit" class="btn btn-primary">Login</button>
							</p>
						</fieldset>
					</form>
				</div>
				<!--/span-->
			</div>
			<!--/row-->
		</div>
		<!--/fluid-row-->

	</div>
	<!--/.fluid-container-->
</body>
</html>